<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>25题寻找完美数</title>
    <script>
        function getPerfectNumber() {
            let numArr = [];
            for (let i = 6; i <= 10000; i++) {
                let n = i;
                let count = 0;
                for (let j = 1; j < n; j++) {
                    if (n % j === 0) {
                        count += j;
                    }
                }
                if (count === n) {
                    numArr.push(n);
                }
            }
            
            let p = document.getElementById('sum');
            p.innerHTML = '1~10000之间所有的完美数：' + numArr.toString();
        }
    </script>
</head>
<body>
    <p>
        点击按钮查看1~10000之间所有的完美数<input type="button" value="查看" onclick="getPerfectNumber()">
    </p>
    <p id="sum">1~10000之间所有的完美数：</p>
</body>
</html>